//
//  NYMineForm.m
//  NYTYY
//
//  Created by MinLison on 2017/12/8.
//  Copyright © 2017年 NYtyy. All rights reserved.
//

#import "NYMineForm.h"
#import "NYGoodSubjectBookViewController.h"
#import "NYWrongSubjectBookViewController.h"
#import "NYMyClassesViewController.h"
#import "NYMyExamineViewController.h"
#import "NYMyAirlineViewController.h"
#import "NYMyVideoMsgViewController.h"
#import "NYMyExamineMsgViewController.h"

#import "NYLearnRecordViewController.h"

NSString *const NYMineFormRowDescriptorTypeCustom = @"NYMineFormRowDescriptorTypeCustom";
NSString *const NYMineFormOptionsObjectControllerKey = @"NYMineFormOptionsObjectControllerKey";
NSString *const NYMineFormOptionsObjectImageKey = @"NYMineFormOptionsObjectImageKey";
NSString *const NYMineFormOptionsObjectTitleKey = @"NYMineFormOptionsObjectTitleKey";
@implementation NYMineForm
- (instancetype)initWithTitle:(NSString *)title
{
        self = [super initWithTitle:title];
        if (self) {
                [self initializeForm];
        }
        return self;
}
- (void)initializeForm
{
        __block XLFormSectionDescriptor * section;
        __block XLFormRowDescriptor * row;
        UITableViewCell *cell;
        // 顶部四个视图
        section = [XLFormSectionDescriptor formSectionWithTitle:@"收藏和消息"];
        [self addFormSection:section];
        row = [XLFormRowDescriptor formRowDescriptorWithTag:@"收藏和消息" rowType:NYMineFormRowDescriptorTypeCustom];
        row.cellClass = [NYMineOrderCell class];
        row.height = __WGHeight(55);
        [section addFormRow:row];
        
        section = [XLFormSectionDescriptor formSectionWithTitle:nil];
        [self addFormSection:section];
        NSArray <NSString *>*normalCellTitles = @[@"好题本",
                                                  @"错题本",
                                                  @"我的课程",
                                                  @"我的考试",
                                                  @"我的疑问",
                                                  @"我的视频留言",
                                                  @"我的考试留言",
                                                  @"学习记录"
                                                  ];
        NSArray <UIImage *>*normalCellImgs =     @[[UIImage hao_ti_ben],
                                                   [UIImage cuo_ti_ben],
                                                   [UIImage wo_de_ke_cheng],
                                                   [UIImage wo_de_kao_shi],
                                                   [UIImage wo_de_yi_wen],
                                                   [UIImage wo_de_shi_pin],
                                                   [UIImage wo_de_liu_yan],
                                                   UIImageMake(@"xue_xi_ji_lu")
                                                   ];
        NSArray <Class>*normalCellTargetClass = @[[NYGoodSubjectBookViewController class],
                                                  [NYWrongSubjectBookViewController class],
                                                  [NYMyClassesViewController class],
                                                  [NYMyExamineViewController class],
                                                  [NYMyAirlineViewController class],
                                                  [NYMyVideoMsgViewController class],
                                                  [NYMyExamineMsgViewController class],
                                                  [NYLearnRecordViewController class]
                                                  ];
        [normalCellTitles enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:NYMineFormRowDescriptorTypeCustom title:obj];
                row.cellClass = [NYMineNormalCell class];
                row.height = __WGHeight(51);
                row.image = normalCellImgs[idx];
                row.opaque = @(1); /// 需要登录
                row.action.viewControllerPresentationMode = XLFormPresentationModePush;
                [row.cellConfig setObject:@(UITableViewCellSelectionStyleNone) forKey:@keypath(cell,selectionStyle)];
                row.action.viewControllerClass = normalCellTargetClass[idx];
                [section addFormRow:row];
        }];
        
        section = [XLFormSectionDescriptor formSectionWithTitle:nil];
        [self addFormSection:section];
}
@end
